package copyengine.utils.commandQueue
{

	public final class CECommandExecuteWarp
	{
		private var commandExecuterVector:Vector.<ICECommandExecuter>;

		//整个Execute执行结束后的回调函数
		private var endCallBackFunction:Function;

		//完成的Executer计数
		private var finishExecuterCount:int;

		public function CECommandExecuteWarp()
		{
		}

		public function initialize(_endCallBack:Function):void
		{
			commandExecuterVector = new Vector.<ICECommandExecuter>();
			endCallBackFunction = _endCallBack;
		}

		public function dispose():void
		{
			commandExecuterVector.length = 0;
			commandExecuterVector = null;
			endCallBackFunction = null;
		}

		public function addExecuter(_commandExecuter:ICECommandExecuter):void
		{
			commandExecuterVector.push(_commandExecuter);
		}

		public function startExecute():void
		{
			for each (var executer:ICECommandExecuter in commandExecuterVector)
			{
				executer.onExecute();
			}
		}

		public function onExecuterFinish():void
		{
			finishExecuterCount++;
			if (finishExecuterCount >= commandExecuterVector.length)
			{
				endCallBackFunction && endCallBackFunction();
			}
		}

	}
}
